home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 3844 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.2 KB

  1. Path: news.compuserve.com!newsmaster
  2. From: 100754.2730@compuserve.com (Martin Aupperle)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Q: Returning a reference
  5. Date: Fri, 26 Jan 1996 10:01:04 GMT
  6. Organization: CompuServe Incorporated
  7. Message-ID: <4ea93s$kq6@dub-news-svc-1.compuserve.com>
  8. References: <4cvsm2$5ig@dub-news-svc-4.compuserve.com> <30F53184.C57@dinamero.com>
  9. NNTP-Posting-Host: ad02-055.compuserve.com
  10. X-Newsreader: Forte Free Agent v0.56
  11.  
  12. "Robert S. Stull" <stullr@dinamero.com> wrote:
  13.  
  14.  
  15. >> int &doIt() {
  16. >> 
  17. >>   int i = 7;
  18. >>   return i;  // syntax error
  19. >>   }
  20. >> 
  21.  
  22. [snip]
  23.  
  24. >Try this:
  25. >    static int i = 7;
  26. >Most compilers allow it and it will still be valid when you exit 
  27. >the function.
  28.  
  29. Not only most, but all should allow that - the static variable remains
  30. alive until the program terminates. No problem so far, because the
  31. reference always has a object it is bound to, i.e the lifetime of the
  32. object is equal/longer than that of the reference. But what happens if
  33. the lifetime of a reference is LONGER than that of the referent?
  34. Does/should the language allow that?
  35.  
  36.  
  37.  
  38.  
  39. -----------------------------------
  40. Signatures are a waste of bandwidth
  41. -----------------------------------
  42.  
  43.